<template>
    <el-container>
  <el-header>
    <div id="title">课程班级</div>
                <div><i class="el-icon-search" id="icon" ></i></div>
                <el-input v-model="input" placeholder="搜索课程" id="input"></el-input>
                <div id="jia">加入班级</div>
                <div id="tong">通知</div>
                <div><i class="el-icon-user-solid" id="icon1" @click="handleicon"></i></div>
  </el-header>
  <el-main style="background-color: white;">
    <el-table
    :data="stu"
    style="width: 100%">
    <el-table-column
      prop="id"
      label="序号">
    </el-table-column>
    <el-table-column
      prop="name"
      label="学生姓名">
    </el-table-column>
    <el-table-column
      prop="number"
      label="学生学号">
    </el-table-column>
    <el-table-column
      prop="data"
      label="提交时间">
    </el-table-column>
    <el-table-column
      prop="grade"
      label="成绩">
    </el-table-column>
    <el-table-column
      fixed="right"
      label="操作"
      width="100">
      <template slot-scope="scope">
        <el-button @click="handleClick(scope.row)" type="text" size="small">查看</el-button>
      </template>
    </el-table-column>
  </el-table>
  </el-main>
</el-container>
</template>
<style>
.grid-cotainer{
    display:grid;
    grid-template-columns: repeat(3,300px);
    grid-gap:50px;
}
.grid-item{
    padding: 20px;
    border:1px solid;
    border-radius: 5px;
}
  .el-col {
    border-radius: 4px;
  }
  .el-row {
    margin-bottom: 20px;
  }
  .bg-purple-light {
    background: #0c2152;
  }
  .bg-purple-dark {
    background: #830608;
  }
  .el-header{
    background-color: rgb(85,85,85);
    color: #333;
    text-align: center;
    line-height: 80px;
  }
  .el-main {
    background-color: #E9EEF3;
    color: #333;
    text-align: center;
    line-height: 160px;
  }
  
  body > .el-container {
    margin-bottom: 40px;
  }
  
  .el-container:nth-child(5) .el-aside,
  .el-container:nth-child(6) .el-aside {
    line-height: 260px;
  }
  
  .el-container:nth-child(7) .el-aside {
    line-height: 320px;
  }
  #title{
    color: #E9EEF3;
    position:absolute;
    top: 0px;
    left:80px;
  }
  #icon{
    color: white;
    font-size: 25px;
    position: absolute;
    top:30px;
    left:700px;
  }
  #input{
    height:33px;
    width:230px;
    position: absolute;
    top:-30px;
    left:700px;
  }
  #jia{
    color: #E9EEF3;
    position:absolute;
    top: 0px;
    left:1000px;
  }
  #tong{
    color: #E9EEF3;
    position:absolute;
    top: 0px;
    left:1200px;
  }
  #icon1{
    color: white;
    font-size:40px;
    position: absolute;
    top:20px;
    left: 1350px;
  }
</style>
<script>
import axios from 'axios'
export default {
    data(){
        return{
          stu:[],
          id:'',
          courseid:''
        }
    },
    methods:{
        handleicon(){
          this.$router.push('/StuPage')
        },
        handleClick(row){
          this.$router.push({
          name:'NeiRong',
          params:{
            id:row.id,//学生id
            courseid:this.courseid,//课程id
            taskid:this.taskid//任务id
          }
        })
        }
    },
    mounted(){
            this.id=this.$route.params.id//课程id
            this.courseid=this.$route.params.courseid//任务id
            //传出 id-课程id courseid-任务id
            //返回 stu数组，格式如下
            axios.post('http://127.0.0.1:4523/m2/5591894-5270100-default/244513097?apifoxApiId=244513097',{
            id:this.id,
            courseid:this.courseid
          }).then(res=>{
            this.stu=res.data.stu
          })
        }
}
/* 
"stu": [
        {
            "data": "2016-05-02",
            "name": "王小虎",
            "id": "1",
            "number": "1241412",
            "grade": "未完成"
        },
        {
            "data": "2016-05-02",
            "name": "王小虎",
            "id": "2",
            "number": "1241412",
            "grade": "59"
        },
        {
            "data": "2016-05-02",
            "name": "王小虎",
            "id": "3",
            "number": "1241412",
            "grade": "79"
        },
        {
            "data": "2016-05-02",
            "name": "王小虎",
            "id": "4",
            "number": "1241412",
            "grade": "100"
        }
    ]
    */
</script>